// #####################################
// File     : HAL.c
// Author   : Chris Meaclem, Chris McPherson, Isaac, Andrew
// Date     : 28/07/2011
// Release  : Intermediate
// Purpose  : Provide abstraction of hardware details to higher level functions.
// Notes    : 
// #####################################

/*Includes:*/
#include "HAL.h"

/*END - Includes:*/
/*Definitions:*/


/*END - Definitions:*/
/*Globals:*/


/*END - Globals:*/


#define uint unsigned integer

/*Put pins to sleep that are not in use?*/

/*From datasheet page 55:
The following code example shows how to set port B pins 0 and 1 high, 2 and 3 low, and define
the port pins from 4 to 7 as input with pull-ups assigned to port pins 6 and 7. The resulting pin
values are read back again, but as previously discussed, a nop instruction is included to be able
to read back the value recently assigned to some of the pins.


//Define pull-ups and set outputs high
//Define directions for port pins
PORTB = (1<<PB7)|(1<<PB6)|(1<<PB1)|(1<<PB0);
DDRB = (1<<DDB3)|(1<<DDB2)|(1<<DDB1)|(1<<DDB0);
//Insert nop for synchronization
_NOP();
//Read port pins
i = PINB;
*/

/*
Datasheet page 54
Unconnected pins:
If some pins are unused, it is recommended to ensure that these pins have a defined level. Even
though most of the digital inputs are disabled in the deep sleep modes as described above, floating
inputs should be avoided to reduce current consumption in all other modes where the digital
inputs are enabled (Reset, Active mode and Idle mode).
The simplest method to ensure a defined level of an unused pin, is to enable the internal pull-up.
In this case, the pull-up will be disabled during reset. If low power consumption during reset is
important, it is recommended to use an external pull-up or pull-down. Connecting unused pins
directly to VCC or GND is not recommended, since this may cause excessive currents if the pin is
accidentally configured as an output.
*/



void hal_SetOutput(uint pinNum, int value)
{
	/* Description:
	* function to set output state on given pin
	* Scope: Global.
	* Input: 
	*/
}

int hal_GetInput(uint pinNum)
{
	/* Description:
	* function to return input value from given pin
	* Scope: Global.
	* Input: 
	* Output: Will return -1 on error, else +ve in <1024
	*/
	int value = -1;/*Set to -1 to indicate error state if not action occurs*/
	
	//do stuff, ADC?
	
	return value;	
}

static void hal_ConfigDiscon()
{
/* Description:
	* Configure unused pins to avoid high power consumption in non-sleep modes. See datasheet page 54
	* Scope: Internal.
	*/

}
